package com.xiguaji.tiktok.v1.tiktok.permission.repository;

import com.xiguaji.tiktok.v1.tiktok.permission.model.UserRole;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Optional;

@Repository
public interface UserRoleRepository extends CrudRepository<UserRole,Long> {

    Optional<UserRole> findTop1ByUserIdAndExpireTimeGreaterThanEqualOrderByRoleIdDesc(long userId, Date expireTime);

    List<UserRole> findByUserIdOrderByExpireTimeDesc(long userId);

    UserRole findByUserIdAndRoleId(long userId,long roleId);
}
